home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_apache2.idb / usr / freeware / apache2 / include / apr_base64.h.z / apr_base64.h
C/C++ Source or Header  |  2002-07-08  |  6KB  |  151 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * The apr_vsnprintf/apr_snprintf functions are based on, and used with the
  55.  * permission of, the  SIO stdio-replacement strx_* functions by Panos
  56.  * Tsirigotis <panos@alumni.cs.colorado.edu> for xinetd.
  57.  */
  58.  
  59. /**
  60.  * @file apr_base64.h
  61.  * @brief APR-UTIL Base64 Encoding
  62.  */
  63. #ifndef APR_BASE64_H
  64. #define APR_BASE64_H
  65.  
  66. #include "apu.h"
  67. #include "apr_general.h"
  68.  
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif
  72.  
  73. /**
  74.  * @defgroup APR_Util_Base64 Base64 Encoding
  75.  * @ingroup APR_Util
  76.  * @{
  77.  */
  78.  
  79. /* Simple BASE64 encode/decode functions.
  80.  * 
  81.  * As we might encode binary strings, hence we require the length of
  82.  * the incoming plain source. And return the length of what we decoded.
  83.  *
  84.  * The decoding function takes any non valid char (i.e. whitespace, \0
  85.  * or anything non A-Z,0-9 etc as terminal.
  86.  * 
  87.  * plain strings/binary sequences are not assumed '\0' terminated. Encoded
  88.  * strings are neither. But probably should.
  89.  *
  90.  */
  91.  
  92. /**
  93.  * Given the length of an un-encrypted string, get the length of the 
  94.  * encrypted string.
  95.  * @param len the length of an unencrypted string.
  96.  * @return the length of the string after it is encrypted
  97.  */ 
  98. APU_DECLARE(int) apr_base64_encode_len(int len);
  99.  
  100. /**
  101.  * Encode a text string using base64encoding.
  102.  * @param coded_dst The destination string for the encoded string.
  103.  * @param plain_src The original string in plain text
  104.  * @param len_plain_src The length of the plain text string
  105.  * @return the length of the encoded string
  106.  */ 
  107. APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src, 
  108.                                  int len_plain_src);
  109.  
  110. /**
  111.  * Encode an EBCDIC string using base64encoding.
  112.  * @param coded_dst The destination string for the encoded string.
  113.  * @param plain_src The original string in plain text
  114.  * @param len_plain_src The length of the plain text string
  115.  * @return the length of the encoded string
  116.  */ 
  117. APU_DECLARE(int) apr_base64_encode_binary(char * coded_dst, 
  118.                                         const unsigned char *plain_src,
  119.                                         int len_plain_src);
  120.  
  121. /**
  122.  * Determine the length of a plain text string given the encoded version
  123.  * @param coded_src The encoded string
  124.  * @return the length of the plain text string
  125.  */ 
  126. APU_DECLARE(int) apr_base64_decode_len(const char * coded_src);
  127.  
  128. /**
  129.  * Decode a string to plain text
  130.  * @param plain_dst The destination string for the plain text
  131.  * @param coded_src The encoded string 
  132.  * @return the length of the plain text string
  133.  */ 
  134. APU_DECLARE(int) apr_base64_decode(char * plain_dst, const char *coded_src);
  135.  
  136. /**
  137.  * Decode an EBCDIC string to plain text
  138.  * @param plain_dst The destination string for the plain text
  139.  * @param coded_src The encoded string 
  140.  * @return the length of the plain text string
  141.  */ 
  142. APU_DECLARE(int) apr_base64_decode_binary(unsigned char * plain_dst, 
  143.                                         const char *coded_src);
  144.  
  145. /** @} */
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149.  
  150. #endif    /* !APR_BASE64_H */
  151.